package com.test.springmvc_demo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Slf4j
@Controller
@RequestMapping("/api")
public class HelloController {
    //访问hello2方法，使用url： http://localhost:8080/api/hello2
    @RequestMapping("/hello2")
    public String hello(){
        log.info("hello2");
        return "/ch9-1.html";
    }

    @RequestMapping(value = "/hello2",method = RequestMethod.POST)
    public String hello3(){
        log.info("hello3");
        System.out.println("hello3");
        return "/ch9-1.html";
    }

    //通过在url中添加name参数，访问hello4方法，使用url： http://localhost:8080/api/hello2?name=zhangsan
    @RequestMapping(value = "/hello2",params = "name")
    public String hello4(){
        log.info("hello4");
        return "/ch9-1.html";
    }
}